package pl.edu.pw.MidEmu.Common.Models;

import java.io.Serializable;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Vector;

/**
 * Model class representing MIDAS application
 * Cotains application settings
 * @author Mateusz Starodab
 *
 */
public class ClassSettingsModel implements Serializable
{
	private static final long serialVersionUID = 3822476372828263380L;

	private String _className;
	
	private String _classPath;
	
	private String _JVMparameters;
	
	private String _package;
	
	private String _parameters;
	
	private String _path;
	
	private String _workDir;

	/**
	 * Adds data row for displaying in generic data grid
	 * @param data Vector of data
	 * @param name Property name
	 * @param value Property value
	 */
	protected void addData(Vector<Vector<String>> data, String name, String value)
	{
		Vector<String> row = new Vector<String>();
		row.add(name);
		row.add(value);

		data.add(row);
	}

	@Override
	/**
	 * Check two applications for equality
	 */
	public boolean equals(Object obj)
	{
		if (obj != null)
			if (obj instanceof ClassSettingsModel)
				return this._path.equals(((ClassSettingsModel) obj).get_path());
		return super.equals(obj);
	}

	/**
	 * Gets class name
	 * @return Class name
	 */
	public String get_className()
	{
		return _className;
	}

	/**
	 * Gets class path
	 * @return Class path
	 */
	public String get_classPath()
	{
		return _classPath;
	}
	
	/**
	 * Gets JVM parameters
	 * @return JVM parameters
	 */
	public String get_JVMparameters()
	{
		return _JVMparameters;
	}

	/**
	 * Gets package name
	 * @return Package name
	 */
	public String get_package()
	{
		return _package;
	}

	/**
	 * Gets command line parameters
	 * @return Parameters
	 */
	public String get_parameters()
	{
		return _parameters;
	}

	/**
	 * Gets path
	 * @return Path
	 */
	public String get_path()
	{
		return _path;
	}

	/**
	 * Gets work directory
	 * @return work directory
	 */
	public String get_workDir()
	{
		return _workDir;
	}

	/**
	 * Gets application data for display in generic data grid
	 * @return Vector of data
	 */
	public Vector<Vector<String>> getClassData()
	{
		Vector<Vector<String>> data = new Vector<Vector<String>>();

		addData(data, "Class name", _className);
		addData(data, "Class path", _classPath);
		addData(data, "Package", _package);
		addData(data, "JVM Parameters", _JVMparameters);
		addData(data, "Parameters", _parameters);
		addData(data, "Path", _path);
		addData(data, "Working directiory", _workDir);

		return data;
	}

	@Override
	/**
	 * Gets hashcode
	 */
	public int hashCode()
	{
		return super.hashCode();
	}

	/**
	 * Sets class name
	 * @param className Class name
	 */
	public void set_className(String className)
	{
		_className = className;
	}

	/**
	 * Setc class path
	 * @param classPath Clas path
	 */
	public void set_classPath(String classPath)
	{
		_classPath = classPath;
	}

	/**
	 * Sets JVM parameters
	 * @param parameters JVM parameters
	 */
	public void set_JVMparameters(String parameters)
	{
		_JVMparameters = parameters;
	}

	/**
	 * Sets package name
	 * @param packageName Package name
	 */
	public void set_package(String packageName)
	{
		_package = packageName;
	}

	/**
	 * Sets command line parameters
	 * @param _parameters Parameters
	 */
	public void set_parameters(String _parameters)
	{
		this._parameters = _parameters;
	}

	/**
	 * Sets path
	 * @param path Path
	 */
	public void set_path(String path)
	{
		_path = path;
	}

	/**
	 * Sets working directory
	 * @param workDir Working directory
	 */
	public void set_workDir(String workDir)
	{
		_workDir = workDir;
	}

	@Override
	/**
	 * Returns string representation of this Class settings model
	 */
	public String toString()
	{
		return get_className() + " - " + DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(Calendar.getInstance().getTime());
	}
}
